package com.woniuxy.controller;

import com.woniuxy.entity.RbacRole;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.RbacRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/rbacRole")
public class RbacRoleController {
    @Autowired
    RbacRoleService rbacRoleService;
    @GetMapping("/{currentPage}/{pageSize}")
    public ResponseEntity findAll(@PathVariable("currentPage") int currentPage,@PathVariable("pageSize") int pageSize){
        return rbacRoleService.findAll(currentPage,pageSize);
    }
//    @GetMapping("/{id}")
//    public ResponseEntity findOne(@PathVariable("id") int id){
//        return rbacRoleService.findOne(id);
//    }
    @PostMapping("/")
    public ResponseEntity addOne(@RequestBody RbacRole rbacRole){
        return rbacRoleService.addOne(rbacRole);
    }
    @DeleteMapping("/{id}")
    public ResponseEntity deleteOne(@PathVariable int id){
        return rbacRoleService.deleteOne(id);
    }
    @PutMapping("/")
    public ResponseEntity updateOne(@RequestBody RbacRole rbacRole){
        return rbacRoleService.updateOne(rbacRole);
    }
    @GetMapping("/{id}")
    public ResponseEntity editType(@PathVariable int id){
        return rbacRoleService.editType(id);
    }
    @GetMapping("/{currentPage}/{pageSize}/{name}/{code}")
    public ResponseEntity search(@PathVariable int currentPage, @PathVariable int pageSize, @PathVariable String name, @PathVariable String code) {
        return rbacRoleService.search(currentPage, pageSize, name, code);
    }
}
